
package com.insigma.business.qrcode.common.converter;


import com.insigma.business.qrcode.common.dto.SystemConfigDTO;
import com.insigma.business.qrcode.common.dto.SystemConfigInsertRequest;
import com.insigma.business.qrcode.soldier.entity.SystemConfigDO;
import com.insigma.business.qrcode.soldier.request.SystemConfigUpdateRequest;
import org.springframework.beans.BeanUtils;

import java.util.List;


public class SystemConfigProviderConverter extends
        AbstractConverter<SystemConfigDTO, SystemConfigDO> {

    private final static SystemConfigProviderConverter systemConfigConverter = new SystemConfigProviderConverter();

    private SystemConfigProviderConverter(){}


    
    public static SystemConfigDO convertRequestUO2DO(final SystemConfigUpdateRequest systemConfigUpdateRequest) {
        final SystemConfigDO systemConfigDO = new SystemConfigDO();
        BeanUtils.copyProperties(systemConfigUpdateRequest,systemConfigDO);
        
        return systemConfigDO;
    }

    
    public static SystemConfigDO convertRequestIO2DO(final SystemConfigInsertRequest systemConfigInsertRequest) {
        final SystemConfigDO systemConfigDO = new SystemConfigDO();
        BeanUtils.copyProperties(systemConfigInsertRequest,systemConfigDO);
        return systemConfigDO;
    }

    
    public static List<SystemConfigDTO> convertResponseDOList2DTOList(final List<SystemConfigDO> systemConfigDOList){
        return systemConfigConverter.convertGenericResponseDOList2DTOList(systemConfigDOList);
    }

    
    public static SystemConfigDTO convertResponseDO2DTO(final SystemConfigDO systemConfigDO){
        return systemConfigConverter.convertGenericResponseDO2DTO(systemConfigDO);
    }

    
    @Override
    protected SystemConfigDTO doConvertResponseDO2DTO(SystemConfigDO systemConfigDO) {
        final SystemConfigDTO systemConfigDTO = new SystemConfigDTO();
        try {
            BeanUtils.copyProperties(systemConfigDO, systemConfigDTO);
        }catch(RuntimeException be){
            
            return null;
        }
        return systemConfigDTO;
    }

}
